from django.db import models
from django.contrib.auth.models import AbstractUser
from datetime import datetime
# Create your models here.


class UserProfile(AbstractUser):
    """
    用户
    """
    name = models.CharField(max_length=30, null=True, blank=True, help_text='姓名')
    birthday = models.DateField(null=True, blank=True, help_text='出生日期')
    mobile = models.CharField(max_length=11, null=True, blank=True, help_text='手机号')
    gender = models.CharField(max_length=6, choices=(("male", "男"), ("female", "女")), default="male")
    email = models.EmailField(max_length=100, null=True, blank=True, help_text='邮箱')

    class Meta:
        verbose_name = "用户"
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.username


class VerifyCode(models.Model):
    """
    短信验证码
    """
    code = models.CharField(max_length=10, help_text='验证码')
    mobile = models.CharField(max_length=11, null=True, blank=True, help_text='手机号')
    add_time = models.DateTimeField(default=datetime.now, help_text='添加时间')

    class Meta:
        verbose_name = "短信验证码"
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.mobile
